<!DOCTYPE html>
<html>
<head>
  <meta content="IE=11.0000" http-equiv="X-Ua-Compatible">
  <meta charset="utf-8">
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-Ua-Compatible" content="IE=edge,chrome=1">

  <title>弹窗3</title>
  <!--region 引入公用js和css -->
  <link href="../assets/plugins/animate/animate.css" rel="stylesheet">
  <link href="../assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
  <link href="../assets/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css"/>
  <link href="../assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
  <link href="../assets/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css"/>
  <link href="../assets/plugins/fullcalendar/fullcalendar.css" rel="stylesheet" type="text/css"/>
  <link href="../assets/base/css/components.css" rel="stylesheet" id="style_components" type="text/css"/>
  <link href="../assets/base/css/plugins.css" rel="stylesheet" type="text/css"/>
  <link href="../assets/ditop/layout.css" rel="stylesheet" type="text/css"/>
  <link href="../assets/plugins/datatables/datatables.min.css" rel="stylesheet" type="text/css"/>
  <link href="../assets/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css" rel="stylesheet" type="text/css"/>
  <link href="../assets/plugins/bootstrap-table/bootstrap-table.css" rel="stylesheet">
  <link href="../assets/plugins/bootstrap-table/extensions/tree-column/bootstrap-table-tree-column.css" rel="stylesheet">
  <link href="../assets/plugins/bootstrap-toastr/toastr.css" rel="stylesheet">
  <link rel="stylesheet" href="../assets/plugins/sweetalert/sweetalert.css">
  <link rel="stylesheet" href="../assets/plugins/layer/theme/default/layer.css">
  <link href="../assets/plugins/select2/css/select2.min.css" rel="stylesheet">
  <link href="../assets/plugins/icheck/skins/flat/aero.css" rel="stylesheet">
  <link href="../assets/ditop/ditop.css" rel="stylesheet">
  <link href="../assets/ditop/style/ztree/style9/treestyle.css" rel="stylesheet">
  <link href="../assets/plugins/bootstrap-touchspin/bootstrap.touchspin.css" rel="stylesheet">
  <link href="../assets/plugins/bootstrap-datepicker/css/bootstrap-datepicker3.min.css" rel="stylesheet" type="text/css"/>
  <script src="../assets/plugins/jquery/jquery.min.js"></script>
  <script src="../assets/plugins/bootstrap/js/bootstrap.min.js"></script>
  <script src="../assets/plugins/bootstrap-toastr/toastr.js"></script>
  <script src="../assets/plugins/art-template/template.js"></script>
  <script src="../assets/plugins/layer/layer.js"></script>
  <script src="../assets/ditop/ditop.js"></script>
  <link rel="stylesheet" href="../assets/module/common/gcjsy_js.css">
  <link href="../assets/module/gcjsy/css/public.css" rel="stylesheet"> <!-- CSS Customization -->
  <link rel="stylesheet" href="src/split.css">

  <style>
     .mt-checkbox {
      padding-left: 25px;
    }
  </style>
</head>


<body class="page-footer-fixed page-content-white padding-top-30">



<div class="center-block bg-white" style="width: 900px">

  <div class="auto-scroll " style="height: 420px;">
    <div class="padding-top-15 padding-lr-16">

      <label class="query-item">
        <b class="query-title">工程类别</b>
        <select class="querySelect" style="width: 200px;margin-right: 12px">
          <option value="">全部</option>
          <option value="">option1</option>
          <option value="">option2</option>
          <option value="">option3</option>
          <option value="">option4</option>
        </select>
      </label>

      <div class="input-icon right popup-search">
        <i class="fa icon-magnifier"></i>
        <input type="text" class="form-control" placeholder="请输入分部工程">
      </div>
    </div>

    <div class="indx flex-s">
      <div class="inf-left auto-scroll h-100p">
        <ul class="ztree padding-top-20 padding-left-15" id="tree"></ul>
      </div>
      <div class="inf-right padding-top-10">
        <div class="padding-lr-16">
          <h3 class="title3 padding-top-5 margin-bottom-10">
            <span>选择分项工程</span>

            <div class="pull-right">
              <label class="mt-checkbox mt-checkbox-outline table-checkbox checkAll" id="checkAll">
                <input type="checkbox">
                <span></span>
                选择全部
              </label>

            </div>
          </h3>

          <div class="plate-list clearfix auto-scroll" style="height: 308px">
            <label class="mt-checkbox mt-checkbox-outline table-checkbox plate-item">
              <input type="checkbox" >
              <span></span>
              <i class="con">分项工程  1</i>
            </label>
            <label class="mt-checkbox mt-checkbox-outline table-checkbox plate-item">
              <input type="checkbox" >
              <span></span>
              <i class="con">分项工程  1</i>
            </label>
            <label class="mt-checkbox mt-checkbox-outline table-checkbox plate-item">
              <input type="checkbox" >
              <span></span>
              <i class="con">分项工程  1</i>
            </label>
            <label class="mt-checkbox mt-checkbox-outline table-checkbox plate-item">
              <input type="checkbox" >
              <span></span>
              <i class="con">分项工程  1</i>
            </label>
            <label class="mt-checkbox mt-checkbox-outline table-checkbox plate-item">
              <input type="checkbox" >
              <span></span>
              <i class="con">分项工程  1</i>
            </label>
            <label class="mt-checkbox mt-checkbox-outline table-checkbox plate-item">
              <input type="checkbox" >
              <span></span>
              <i class="con">分项工程  1</i>
            </label>
            <label class="mt-checkbox mt-checkbox-outline table-checkbox plate-item">
              <input type="checkbox" >
              <span></span>
              <i class="con">分项工程  1</i>
            </label>
            <label class="mt-checkbox mt-checkbox-outline table-checkbox plate-item">
              <input type="checkbox" >
              <span></span>
              <i class="con">分项工程  1</i>
            </label>
            <label class="mt-checkbox mt-checkbox-outline table-checkbox plate-item">
              <input type="checkbox" >
              <span></span>
              <i class="con">分项工程  1</i>
            </label>
            <label class="mt-checkbox mt-checkbox-outline table-checkbox plate-item">
              <input type="checkbox" >
              <span></span>
              <i class="con">分项工程  1</i>
            </label>
            <label class="mt-checkbox mt-checkbox-outline table-checkbox plate-item">
              <input type="checkbox" >
              <span></span>
              <i class="con">分项工程  1</i>
            </label>
            <label class="mt-checkbox mt-checkbox-outline table-checkbox plate-item">
              <input type="checkbox" >
              <span></span>
              <i class="con">分项工程  1</i>
            </label>
            <label class="mt-checkbox mt-checkbox-outline table-checkbox plate-item">
              <input type="checkbox" >
              <span></span>
              <i class="con">分项工程  1</i>
            </label>

          </div>
        </div>
      </div>
    </div>

  </div>



  <div class="referTo arc border relative">
    <button class="basicsBtn grayLine" id="repulse" href="javascript:;">取消</button>
    <button type="button" class="basicsBtn blue" href="javascript:;">确定</button>
  </div>


</div>

<!--region 引入公用js和css -->
<script src="../assets/plugins/sweetalert/sweetalert.min.js"></script>
<script src="../assets/plugins/jquery.blockui.min.js"></script>
<script src="../assets/plugins/js.cookie.min.js"></script>
<script src="../assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<script src="../assets/plugins/jquery.blockui.min.js"></script>
<script src="../assets/plugins/bootstrap-switch/js/bootstrap-switch.min.js"></script>
<script src="../assets/plugins/bootstrap-touchspin/bootstrap.touchspin.js"></script>
<script src="../assets/plugins/moment.min.js"></script>
<script src="../assets/plugins/bootstrap-daterangepicker/daterangepicker.min.js"></script>
<script src="../assets/plugins/counterup/jquery.waypoints.min.js"></script>
<script src="../assets/plugins/counterup/jquery.counterup.min.js"></script>
<script src="../assets/plugins/fullcalendar/fullcalendar.js"></script>
<script src="../assets/plugins/horizontal-timeline/horizontal-timeline.js"></script>
<script src="../assets/plugins/jquery.sparkline.min.js"></script>
<script src="../assets/plugins/select2/js/select2.js"></script>
<script src="../assets/plugins/select2/js/i18n/zh-CN.js"></script>
<script src="../assets/plugins/ztree/jquery.ztree.all.js"></script>
<script src="../assets/plugins/jquery-form/jquery.form.js"></script>
<script src="../assets/plugins/jquery-validator/jquery.placeholder.min.js"></script>
<script src="../assets/plugins/jquery-validator/jquery.validate.js"></script>
<script src="../assets/plugins/jquery-validator/jquery.validate.custom.js"></script>
<script src="../assets/plugins/jquery-validator/localization/messages_zh.js"></script>
<script src="../assets/plugins/jquery-validator/additional-methods.js"></script>
<script src="../assets/plugins/bootstrap-growl/jquery.bootstrap-growl.js"></script>
<script src="../assets/plugins/bootstrap-table/bootstrap-table.js"></script>
<script src="../assets/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>
<script src="../assets/plugins/bootstrap-table/extensions/tree-column/bootstrap-table-tree-column.js"></script>
<script src="../assets/base/scripts/app.js"></script>
<script src="../assets/base/scripts/theme.js"></script>
<script src="../assets/ditop/ditop-addition.js"></script>
<script src="../assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.js" type="text/javascript"></script>
<script src="../assets/plugins/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"
        type="text/javascript"></script>
<script type="text/javascript" src="../assets/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"
        charset="UTF-8"></script>
<script type="text/javascript"
        src="../assets/plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"
        charset="UTF-8"></script>
<script src="../assets/plugins/jquery-validator/jquery.validate.custom.js"></script>
<script src="../assets/ditop/layout.js"></script>
<!--endregion-->
<script>
  const treeData = [
    {
      "code": "XXXXX",
      "name": "地基与基础",
      "children":[
        {
          "code": "XXXXX",
          "name": "安徽德拓信（75）",
          "children":[
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            },
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            }
          ]
        }, {
          "code": "XXXXX",
          "name": "安徽德拓信（75）",
        },
        {
          "code": "XXXXX",
          "name": "安徽德拓信（75）",
          "children":[
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            },
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            }
          ]
        },
        {
          "code": "XXXXX",
          "name": "安徽德拓信（75）",
          "children":[
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            },
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            }
          ]
        },
        {
          "code": "XXXXX",
          "name": "安徽德拓信（75）",
          "children":[
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            },
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            }
          ]
        },
        {
          "code": "XXXXX",
          "name": "安徽德拓信（75）",
          "children":[
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            },
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            }
          ]
        },
      ]
    },{
      "code": "XXsXXX",
      "name": "地基与基础2",
      "children":[
        {
          "code": "XXXXX",
          "name": "安徽德拓信（75）",
          "children":[
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            },
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            }
          ]
        }, {
          "code": "XXXXX",
          "name": "安徽德拓信（75）",
        },
        {
          "code": "XXXXX",
          "name": "安徽德拓信（75）",
          "children":[
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            },
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            }
          ]
        },
        {
          "code": "XXXXX",
          "name": "安徽德拓信（75）",
          "children":[
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            },
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            }
          ]
        },
        {
          "code": "XXXXX",
          "name": "安徽德拓信（75）",
          "children":[
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            },
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            }
          ]
        },
        {
          "code": "XXXXX",
          "name": "安徽德拓信（75）",
          "children":[
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            },
            {
              "code": "XXXXX",
              "name": "安徽德（75）",
            }
          ]
        },
      ]
    }];
  var $tree = $("#tree"), zTreeObj;
  function init() {
    zTreeObj = $.fn.zTree.init($tree, {
      data: {
        key: {
          name: "name",
          code: "code"
        },
      },
      edit: {
        drag: {
          prve: true,
          next: true
        },
        enable: true,
        showRemoveBtn: setRemoveBtn,
        showRenameBtn: setRenameBtn,
        removeTitle: "删除节点",
        enameTitle: "编辑节点名称",
      },
      view: {
        addHoverDom: addHoverDom,
        removeHoverDom: removeHoverDom,
        // showLine: false
      },
      callback: {
        // onCheck: onCheck,
        // onClick:onClick
      }
    }, treeData);
  }
  init();
  function addHoverDom(treeId, treeNode) {
    var aObj;
    var addStr = "<span class='button add' id=" + treeNode.tId + "_add title='添加子节点' onclick=''></span>";
    if (treeNode.tId === 'tree_1') {
      aObj = $("#" + treeNode.tId + "_span");
      if (aObj.next().hasClass('add')) return;
      aObj.after(addStr);
    } else {
      aObj = $("#" + treeNode.tId + "_edit");
      if (aObj.prev().hasClass('add')) return;
      aObj.before(addStr);
    }
    var btn = $("#" + treeNode.tId + "_add");
    if (btn) btn.bind("click", function () {
      var newNode = {name: ""};
      var newNodez = zTreeObj.addNodes(treeNode, newNode);
      zTreeObj.editName(newNodez[0]);
    });
  }
  function removeHoverDom(treeId, treeNode) {
    $("#" + treeNode.tId + "_add").unbind().remove();
  }
  function setRemoveBtn(treeId, treeNode) {
    return treeNode.tId !== 'tree_1';
  }
  function setRenameBtn(treeId, treeNode) {
    return treeNode.tId !== 'tree_1';
  }
  $('#addTree').click(function () {
    var bObj=$("#tree_1_span");
    console.log(bObj)
    var addStr = "<span class='button add' id=" + treeNode.tId + "_add title='添加子节点' onclick=''></span>";
    if (bObj.next().hasClass('add')) return;
    bObj.after(addStr);

  })



  /*-------------------------*/
  /*下面模拟选框选中*/


  $('.plate-list').children('.plate-item').click(function (e) {
    e.preventDefault();
    if($(this).hasClass('disabled')) return false;
    var input = $(this).children('input');
    var checked = input.get(0).checked;
    if (!checked) {
      input.prop("checked", true);
      $(this).addClass('active');
      isAllChecked()
    }else {
      input.prop("checked", false);
      $(this).removeClass('active');
      $('#checkAll').children('input').prop("checked", false)
    }
  });

  $('#checkAll').click(function (e){
    e.preventDefault();
    var input = $(this).children('input');
    var checked = input.get(0).checked;
    if (!checked){
      input.prop("checked", true);
      $('.plate-item').each(function () {
        if(!$(this).hasClass('disabled')){
          $(this).addClass('active').children('input').prop("checked", true)
        }
      })
    }else {
      input.prop("checked", false);
      $('.plate-item').each(function () {
        $(this).removeClass('active').children('input').prop("checked", false)
      })
    }
  });

  function isAllChecked() {
    var isAllChecked = true;
    $('.plate-item').each(function () {
      if(!$(this).hasClass('disabled') && !$(this).children('input').get(0).checked){
        isAllChecked = false
      }
    });
    if (isAllChecked){
      $('#checkAll').children('input').prop("checked", true);
    }
  }



</script>
</body>
</html>

